/*
 * Solution.cpp
 *
 *  Created on: 17.10.2010
 *      Author: jilly
 */

#include <iostream>
#include "Solution.h"

using namespace std;

Solution::Solution() {}

Solution::~Solution()
{
	for (list<Move*>::iterator it = moves.begin(); it != moves.end(); it++)
	{
		delete (*it);
	}
}

void Solution::addNextMove(Move* move)
{
	moves.push_back(move);
}

void Solution::addPrevMove(Move* move)
{
	moves.push_front(move);
}

void Solution::removeLastMove()
{
	moves.pop_back();
}

Solution* Solution::clone()
{
	Solution* newSolution = new Solution();
	for (list<Move*>::iterator it = moves.begin(); it != moves.end(); it++)
	{
		newSolution->addNextMove((*it)->clone());
	}
	return newSolution;
}

void Solution::print()
{
	for (list<Move*>::iterator it = moves.begin(); it != moves.end(); it++)
	{
		Move* move = (*it);
		move->print(); cout << ", ";
	}
	cout << endl;
}

list<Move*> Solution::getMoves()
{
	return moves;
}
